﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Framework;
using DomPrint.Common;

namespace DomPrint
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            log4net.Config.DOMConfigurator.Configure(new System.IO.FileInfo("log4netConfig.config"));
            LogHelper.Info("Program start.");


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            DomCommon.ShowError("程序发生意外错误");
            LogHelper.ErrorFormat("CurrentDomain_UnhandledException:{0}", e.ExceptionObject.ToString());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            DomCommon.ShowError("程序发生意外错误");
            LogHelper.ErrorFormat("Application_ThreadException:{0}", e.Exception.Message, e.Exception.StackTrace);
        }

    }
}
